<%
/*Auther name      : Frederic Anand
  file name        : 500.jsp
  date modified    : 17-Feb-2009
  revision history :
*/
%>
<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
	com.ba360.portal.database.dbo.User user = (com.ba360.portal.database.dbo.User)session.getAttribute("USER");
	if (user==null)
	{
	request.setAttribute("USER_NOT_LOGGED_IN","UNPLUGGED");
	%>
	
	<jsp:forward page="/portal/login.do"/>
	
	<%}%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--title>Pune360.com - Pune's complete web portal. Pune Classifieds, Pune Real Estate, Pune News, Pune Writing Wall (Editorial), Pune Jobs.</title-->
<link href="../css/sample1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	background-image: url(../images/main_bg2.gif);
}
.style2 {color: #88DB23}
.style3 {color: #FFFFFF}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<jsp:include page="top.jsp"/>
<br>
<table width="720" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<img src="../images/deals_tab.gif" width="720" height="76" border="0" usemap="#Map" href="../portal/index.do">
		</td>
	</tr>
	<tr>
		<td background="../images/border_bg2.gif">
			<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr> 
					<td colspan="5">
						<%
						String choice = request.getParameter("Action1");
						if (choice!=null && choice.equals("Next"))
						{
							String postingType = request.getParameter("PostingType");
							request.setAttribute("category_id",postingType);
							String catType = request.getParameter("CatType");
							String location = request.getParameter("Location");
							String place = request.getParameter("Place");
						if (postingType==null || postingType.equals("0"))
						{
							request.setAttribute("Error","Posting type not selected");
						}
						else 
						if (location==null || location.equals("0"))
						{
							request.setAttribute("Error","Location not selected");
						}
						else if (postingType!=null && !postingType.equals("0") && location!=null && !location.equals("0")){
							String url = "../portal/newdeals.do?category_id="+postingType+"&CatType="+catType+"&Location="+location+"&Place="+place;
						%>
						<jsp:forward page="<%=url%>"/>
						<%}} else if (choice!=null && choice.equals("Cancel"))
						{
						%>
						<jsp:forward page="../portal/myadlist.do"/>
						<%}%>
						<%
						Class.forName( "com.mysql.jdbc.Driver");
						java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/ba3602_classifiedsdb", "ba3602_portal", "p0rtal" );
						java.sql.Statement stat = conn.createStatement();						
						%>
						<form name="form1" method="post" action="">
						<input type="hidden" name="action" value="NewDeal"/>
							<table border="0" cellpadding="3" cellspacing="1" width="100%" class="text">
								<tr> 
									<td valign="middle" colspan="6" class="title">
										<div align="center"><img src="../images/step1.gif" width="646" height="32"><font color="#CCCCCC"><br>
										<br>
										</font></div>
									</td>
								</tr>
								<tr> 
									<td valign="top" colspan="6"> 
									<% 
									if (request.getAttribute("Error")!=null)
									{
										out.println(request.getAttribute("Error"));	
									}
									%>
									</td>
								</tr>
								<tr> 
									<td valign="top" class="label" width="27%"> 
									<div align="right">Posting Type:</div>
									</td>
									<td valign="top" colspan="5"> 
										<select name="PostingType" onChange="javascript:submit()">
										<%		
										java.sql.ResultSet rs = stat.executeQuery("select name,category_id  from dealscategories where par_category_id is null;");
										String postingType = request.getParameter("PostingType");
										int postingID=0;
										if (postingType!=null && postingType.length()>0 && !postingType.equals("0"))
										{
											postingID = Integer.parseInt(postingType);
										}
										else 
										{
											%>
											<option value="0" selected>--Select a Category--</option>
											<%
										}
											while (rs.next())
											{
												String name = rs.getString(1);
												int id = rs.getInt(2);
												%>
												<%
												if (id==postingID )
												{
													out.println(name +"  "+postingType);
													%>
													<option value="<%=id%>" selected><%=name%></option>
												<%
												} 
												else 
												{%>
													<option value="<%=id%>"><%=name%></option>
										<%
												}
											}	
										%>
										</select>
									</td>
								</tr>
								<tr> 
									<td valign="top" class="label" width="27%"> 
										<div align="right">Sub Category Type:</div>
									</td>
									<td valign="top" colspan="5"> 
										<% 
										if (postingID==0)
										{	%>
											<select name="CatType" onChange="javascript:submit()" disabled='true'>
											<%
										}%>
										<% 
										if (postingID!=0)
										{	%>
											<select name="CatType" onChange="javascript:submit()">
											<%
											rs = stat.executeQuery("select name,category_id  from dealscategories where par_category_id ="+postingID);
											String subcategory_id = request.getParameter("CatType");
											int subidCat=0;
											if (subcategory_id!=null)
											{
												subidCat = Integer.parseInt(subcategory_id);
											}
												while (rs.next())
												{
													String subname = rs.getString(1);
													int subid = rs.getInt(2);			
													%>
													<%
													if (subid==subidCat )
													{			
														%>
														<option value="<%=subid%>" selected><%=subname%></option>
														<%
													} 
													else 
													{	%>
														<option value="<%=subid%>"><%=subname%></option>
														<%
													}
												}
										}	%>
											</select>
									</td>
								</tr>
								<tr> 
									<td valign="top" class="label" width="27%"> 
									<div align="right">Location:</div>
									</td>
									<td colspan="2"> 
										<% 
										if (postingID==0)
										{	%>
											<select name="Location" onChange="javascript:submit()" disabled='true'>
											<%
										}%>
											<% 
										if(postingID!=0)
										{	%>
											<select name="Location" onChange="javascript:submit()">
									<%	}%>
									<%
										String loc = request.getParameter("Location");
										if (loc==null)loc="0";
										if (postingID!=0 && loc.equals("0"))
										{
									%>
											<option value="0">--Select a Location --</option>
											<option value="1">city of san francisco</option>
											<option value="2">south bay area</option>
											<option value="3">east bay area</option>
											<option value="4">peninsula</option>
											<option value="5">north bay/marin</option>
									<%	}%>
									<%	if (loc!=null)
										{
											int locid = Integer.parseInt(loc);
									
									%>
									<% 
											if (locid==1) 
											{%>
												<option value="1" selected>city of san francisco</option>
												<option value="2">south bay area</option>
												<option value="3">east bay area</option>
												<option value="4">peninsula</option>
												<option value="5">north bay/marin</option>
											<%
											}%>
											<% 
											if (locid==2) 
											{%>
												<option value="2" selected>south bay area</option>
												<option value="1">city of san francisco</option>
												<option value="3">east bay area</option>
												<option value="4">peninsula</option>
												<option value="5">north bay/marin</option>
											<%
											}%>
											<% 
											if (locid==3) 
											{%>
												<option value="3" selected>east bay area</option>
												<option value="1">city of san francisco</option>
												<option value="2">south bay area</option>
												<option value="4">peninsula</option>
												<option value="5">north bay/marin</option>
											<%
											}%>
											<% 
											if (locid==4) 
											{%>
												<option value="4" selected>peninsula</option>
												<option value="1">city of san francisco</option>
												<option value="2">south bay area</option>
												<option value="3">east bay area</option>
												<option value="5">north bay/marin</option>
											<%
											}%>
											<% 
											if (locid==5) 
											{%>
												<option value="5" selected>north bay/marin</option>
												<option value="1">city of san francisco</option>
												<option value="2">south bay area</option>
												<option value="3">east bay area</option>
												<option value="4">peninsula</option>
											<%
											}%>
									<%
										}%>
											</select>
									</td>
									<td valign="top" class="label" align="right" width="8%">Place</td>
									<td colspan="2"> 
										<select name="Place">
										<% 
										String location = request.getParameter("Location");
										if (location!=null)
										{
											int locid = Integer.parseInt(location);	
											rs = stat.executeQuery("select name,area_id  from lookup_area where par_category_id ="+locid);
											while (rs.next())
											{
												String locname = rs.getString(1);
												int locID = rs.getInt(2);		
										%>
										<%
												if (locid==locID )
												{		
										%>
													<option value="<%=locID%>" selected><%=locname%></option>
												<%
												} 
												else 
												{%>
													<option value="<%=locID%>"><%=locname%></option>
										<%
												}
											}
										}%>
										</select>
									</td>
								</tr>
								<tr> 
									<td width="27%"></td>
									<td width="13%"></td>
									<td width="16%"></td>
									<td width="8%"></td>
									<td width="20%"></td>
									<td width="16%"></td>
								</tr>
								<tr> 
									<td colspan="6"> 
										<div align="center">
										<input type="submit" name="Action1" value="Cancel" class="button" onClick="javascript:history.back()">
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 
										<input name="Action1" type="submit" class="button" id="Action1" value="Next">
										</div>
									</td>
								</tr>
							</table>
						</form>
						<%conn.close();%>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td><img src="../images/border_bot2.gif" width="719" height="20"></td>
	</tr>
</table>
<br>
<br>
<jsp:include page="../jsp/footer.html"/>
<map name="Map">
	<area shape="rect" coords="131,4,204,74" href="../portal/activities.do">
	<area shape="rect" coords="212,5,292,76" href="../portal/attractions.do">
	<area shape="rect" coords="299,7,368,77" href="../portal/deals.do">
	<area shape="rect" coords="39,10,110,83" href="../jsp/index.jsp">
</map>
</body>
</html>
